<?php

class mobileapi_ctl_admin_info extends desktop_controller{
	
    var $workground = 'mobileapi.wrokground.mobileapi';
	
    public function __construct($app){
        parent::__construct($app);
        $this->app = $app;
        header("cache-control: no-store, no-cache, must-revalidate");
    }	



    function version(){
        if(!$_POST){
            $this->pagedata['version']['aver'] = app::get('mobileapi')->getConf('mobileapi_info.version_aver');
            $this->pagedata['version']['adown'] = app::get('mobileapi')->getConf('mobileapi_info.version_adown');
            $this->pagedata['version']['iver'] = app::get('mobileapi')->getConf('mobileapi_info.version_iver');
            $this->pagedata['version']['idown'] = app::get('mobileapi')->getConf('mobileapi_info.version_idown');
            $this->pagedata['version']['aismust'] = app::get('mobileapi')->getConf('mobileapi_info.version_aismust');
            $this->pagedata['version']['iismust'] = app::get('mobileapi')->getConf('mobileapi_info.version_iismust');
            $this->pagedata['version']['ainfo'] = app::get('mobileapi')->getConf('mobileapi_info.version_ainfo');
            $this->pagedata['version']['iinfo'] = app::get('mobileapi')->getConf('mobileapi_info.version_iinfo');
        }else{
            $this->begin();
            app::get('mobileapi')->setConf('mobileapi_info.version_aver', $_POST['version_aver']);
            app::get('mobileapi')->setConf('mobileapi_info.version_adown', $_POST['version_adown']);
            app::get('mobileapi')->setConf('mobileapi_info.version_iver', $_POST['version_iver']);
            app::get('mobileapi')->setConf('mobileapi_info.version_idown', $_POST['version_idown']);
            app::get('mobileapi')->setConf('mobileapi_info.version_aismust', $_POST['version_aismust']);
            app::get('mobileapi')->setConf('mobileapi_info.version_iismust', $_POST['version_iismust']);
            app::get('mobileapi')->setConf('mobileapi_info.version_ainfo', $_POST['version_ainfo']);
            app::get('mobileapi')->setConf('mobileapi_info.version_iinfo', $_POST['version_iinfo']);
            $this->end(true, app::get('b2c')->_("设置成功！"));
        }
        $this->page('admin/info/version.html');
    }
	
    function about(){
        if(!$_POST){
			$this->pagedata['a_about'] = app::get('mobileapi')->getConf('mobileapi_info.a_about');
			$this->pagedata['i_about'] = app::get('mobileapi')->getConf('mobileapi_info.i_about');
			$this->pagedata['service_tel'] = app::get('mobileapi')->getConf('mobileapi_info.service_tel');
			$this->pagedata['wechat_account'] = app::get('mobileapi')->getConf('mobileapi_info.wechat_account');
			$this->pagedata['weibo_account'] = app::get('mobileapi')->getConf('mobileapi_info.weibo_account');
        }else{
			$this->begin();
			app::get('mobileapi')->setConf('mobileapi_info.a_about', $_POST['a_about']);
			app::get('mobileapi')->setConf('mobileapi_info.i_about', $_POST['i_about']);
			app::get('mobileapi')->setConf('mobileapi_info.service_tel', $_POST['service_tel']);
			app::get('mobileapi')->setConf('mobileapi_info.wechat_account', $_POST['wechat_account']);
			app::get('mobileapi')->setConf('mobileapi_info.weibo_account', $_POST['weibo_account']);
			$this->end(true, app::get('b2c')->_("设置成功！"));
        }
        $this->page('admin/info/about.html');
    }
	
    function feadback(){
        if(!$_POST){
			$this->pagedata['a_about'] = app::get('mobileapi')->getConf('mobileapi_info.a_about');
			$this->pagedata['i_about'] = app::get('mobileapi')->getConf('mobileapi_info.i_about');
        }else{
			$this->begin();
			app::get('mobileapi')->setConf('mobileapi_info.a_about', $_POST['a_about']);
			app::get('mobileapi')->setConf('mobileapi_info.i_about', $_POST['i_about']);
			$this->end(true, app::get('b2c')->_("设置成功！"));
        }
        $this->page('admin/info/about.html');
    }


    function save(){
    	$this->begin();
    	$mdl_info = $this->app->model('info');
    	if ($mdl_info->save($_POST)) {
    		$this->end(true,app::get('b2c')->_('保存成功'));
    	} else {
    		$this->end(true,app::get('b2c')->_('保存失败'));
    	}
    }
	
    function suggest_type(){
        if(!$_POST){
			$suggest_type_str=app::get('mobileapi')->getConf('mobileapi_info.suggest_type');
			$suggest_type_arr=explode('#!!#',$suggest_type_str);
			$this->pagedata['suggest_type'] = $suggest_type_arr;
        }else{
			$this->begin();
			$suggest_type_str=implode('#!!#',$_POST['values']);
			app::get('mobileapi')->setConf('mobileapi_info.suggest_type',$suggest_type_str);
			$this->end(true, app::get('b2c')->_("设置成功！"));
        }
        $this->page('admin/info/suggest_type.html');
    }


}
